﻿<%@ Page Language="C#" MasterPageFile="~/Base.Master" AutoEventWireup="true" CodeBehind="TransactionTypes.aspx.cs" Inherits="SVAccountingWebUI.TransactionTypes" %>
<%@ MasterType VirtualPath="~/Base.Master" %>

<asp:Content ID="TransactionTypes" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" 
        DataKeyNames="TransactionTypeID1" DataSourceID="LDSTransactionTypes"
        onrowcancelingedit="gv_RowCancelingEdit" 
        onrowdeleting="gv_RowDeleting" onrowediting="gv_RowEditing"
        >
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" ImageUrl="~/Icons/Update.png" Text="Update" />
                    &nbsp;<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" ImageUrl="~/Icons/Cancel.png" Text="Cancel" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" ImageUrl="~/Icons/Edit.png" Text="Edit" />
                    &nbsp;<asp:ImageButton ID="DeleteButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" ImageUrl="~/Icons/delete.png" Text="Delete"
                        message="<%$ Resources:Resource, DeleteConfirm %>" 
                        OnClientClick='return confirm(this.getAttribute("message"))'
                        />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="TransactionTypeID1" HeaderText="<%$ Resources:Resource, ID %>" 
                ReadOnly="True" SortExpression="TransactionTypeID1" />
            <asp:TemplateField HeaderText="<%$ Resources:Resource, Group %>" SortExpression="GroupId">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server" 
                        DataSourceID="LDSTransactionGroups" DataTextField="GroupName" 
                        DataValueField="GroupId" SelectedValue='<%# Bind("GroupId") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" 
                        Text='<%# Bind("TransactionTypeGroup.GroupName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Resources:Resource, Mode %>" 
                SortExpression="TransactionModeCode">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList2" runat="server" 
                        DataSourceID="LDSTransactionModes" DataTextField="ModeName" 
                        DataValueField="ModeCode">
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" 
                        Text='<%# Bind("TransactionMode.ModeName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Description" HeaderText="<%$ Resources:Resource, Description %>" 
                SortExpression="Description" />
        </Columns>
    </asp:GridView>
    <asp:LinqDataSource ID="LDSTransactionTypes" runat="server" 
        ContextTypeName="SVAccountingBL.SVALinqDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" TableName="TransactionTypeIDs"
        ondeleted="LinqDataSource_Deleted" 
        onupdated="LinqDataSource_Updated" 
        oninserted="LinqDataSource_Inserted" 
        oninserting="LinqDataSource_Inserting"
        >
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LDSTransactionGroups" runat="server" 
        ContextTypeName="SVAccountingBL.SVALinqDataContext" 
        Select="new (GroupId, GroupName)" TableName="TransactionTypeGroups">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LDSTransactionModes" runat="server" 
        ContextTypeName="SVAccountingBL.SVALinqDataContext" 
        Select="new (ModeCode, ModeName)" TableName="TransactionModes">
    </asp:LinqDataSource>
    
    
    
    <asp:UpdatePanel ID="AddNewPanel" runat="server">
   <ContentTemplate>
    <br />
    <asp:LinkButton ID="lbtnAddNew" runat="server" 
                    Text="<%$ Resources:Resource, AddNew %>" 
           onclick="AddNew_Click"/>
    <br />
    <br />
   <div ID="InsertDiv" runat="server" visible="false">
       <asp:DetailsView ID="dvInsertNew" runat="server" Height="50px" Width="125px" 
           AutoGenerateRows="False" CellPadding="4" DataKeyNames="TransactionTypeID1" 
           DataSourceID="LDSTransactionTypes" DefaultMode="Insert" ForeColor="#333333" 
           GridLines="None" onitemcommand="InsertDV_ItemCommand">
           <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
           <CommandRowStyle BackColor="#FFFFC0" Font-Bold="True" />
           <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
           <FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
           <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
           <Fields>
               <asp:BoundField DataField="TransactionTypeID1" HeaderText="<%$ Resources:Resource, ID %>" 
                   ReadOnly="True" SortExpression="TransactionTypeID1" />
               <asp:TemplateField HeaderText="<%$ Resources:Resource, Group %>" SortExpression="GroupId">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("GroupId") %>'></asp:TextBox>
                   </EditItemTemplate>
                   <InsertItemTemplate>
                       <asp:DropDownList ID="DropDownList3" runat="server" 
                           DataSourceID="LDSTransactionGroups" DataTextField="GroupName" 
                           DataValueField="GroupId" SelectedValue='<%# Bind("GroupId") %>'>
                       </asp:DropDownList>
                   </InsertItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label1" runat="server" Text='<%# Bind("GroupId") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField HeaderText="<%$ Resources:Resource, Mode %>" 
                   SortExpression="TransactionModeCode">
                   <EditItemTemplate>
                       <asp:TextBox ID="TextBox2" runat="server" 
                           Text='<%# Bind("TransactionModeCode") %>'></asp:TextBox>
                   </EditItemTemplate>
                   <InsertItemTemplate>
                       <asp:DropDownList ID="DropDownList4" runat="server" 
                           DataSourceID="LDSTransactionModes" DataTextField="ModeName" 
                           DataValueField="ModeCode" SelectedValue='<%# Bind("TransactionModeCode") %>'>
                       </asp:DropDownList>
                   </InsertItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label2" runat="server" Text='<%# Bind("TransactionModeCode") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:BoundField DataField="Description" HeaderText="<%$ Resources:Resource, Description %>" 
                   SortExpression="Description" />
               <asp:CommandField ButtonType="Image" CancelImageUrl="~/Icons/Cancel.png" 
                   InsertImageUrl="~/Icons/Add.png" NewImageUrl="~/Icons/Add.png" 
                   ShowInsertButton="True" />
           </Fields>
           <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
           <AlternatingRowStyle BackColor="White" />
       </asp:DetailsView>
    </div>
    </ContentTemplate>
    
    <Triggers>
         <asp:AsyncPostBackTrigger ControlID="lbtnAddNew" EventName="click" />
         <asp:PostBackTrigger ControlID="dvInsertNew" /> 
    </Triggers>
    
   </asp:UpdatePanel>
    
    
    
    
    
    
    
</asp:Content>

